package com.candoit.webapps.pricing.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "usuarios")
public class User implements Serializable{

	private static final long serialVersionUID = -2886102311076464201L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id")
	private Integer id;
	
	@ManyToOne
	@JoinColumn(name="perfil_id", referencedColumnName="id")
	private Perfil perfil;
	
	@Column(name = "username")
	private String userName;
	
	@Column(name = "keyword")
	private String keyWord;
	
	@Column(name = "nombre")
	private String nombre;
	
	@Column (name = "apellido")
	private String apellido;
	
	@Column (name = "activo")
	private boolean activo;
	
	@Transient
	private String activoMsg;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Perfil getPerfil() {
		return perfil;
	}

	public void setPerfil(Perfil perfil) {
		this.perfil = perfil;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getKeyWord() {
		return keyWord;
	}

	public void setKeyWord(String keyWord) {
		this.keyWord = keyWord;
	}

	public String getNombre() {
		return nombre;
	}

	public void setNombre(String nombre) {
		this.nombre = nombre;
	}

	public String getApellido() {
		return apellido;
	}

	public void setApellido(String apellido) {
		this.apellido = apellido;
	}

	public boolean isActivo() {
		return activo;
	}

	public void setActivo(boolean activo) {
		this.activo = activo;
	}
	
	
	public String getActivoMsg(){
		if (activo){
			return "Si";
		}else{
			return "No";
		}
	}
	
	public void setActivoMsg(String activoMsg) {
		this.activoMsg = activoMsg;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof User && ((User)obj).getId().equals(this.id)){
			return true;
		}
		return false;
	}
	
	
}
